/**
 * 
 */
package fr.fermeManager.application.views.model;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 * @author Mo
 * 
 */
public class NoteCellRenderer extends DefaultTableCellRenderer {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected, boolean hasFocus, int row, int column) {
		
		super.getTableCellRendererComponent(table, value, isSelected, hasFocus,row, column);

		Double note = (Double) value;
		setText(note.toString());

		if (note < 10) {
			setBackground(Color.RED);
		} else {
			setBackground(Color.GREEN);
		}

		return this;
	}
}
